import { View } from "../../../../mvc/core/View";
import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { ObjCreate } from "../../common/ObjCreate";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { NormalTooltip } from "../../common/tooltip/NormalTooltip";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class PlayerRuneFightBtn
    
    export  class PlayerRuneFightBtn extends View implements IToolTipItem
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public set mode(arg1: string)
        {
            this._mode = arg1;
            if (this._mode == GModuleEvent.Mode_Other || this._mode == GModuleEvent.Mode_Self) 
            {
                this._runeTxt.visible = true;
            }
            else 
            {
                this._runeTxt.visible = false;
            }
            return;
        }

        /* internal  */init(): void
        {
            this._loadedBtn = ObjCreate.createGLoadedButton(ResFileConst.RuneIconBtn, 25, 0, 29, 33, this);
            var loc1=new GTextFormat(FontUtil.EmbedNumberName, 16, 16580352);
            this._runeFightTxt = ObjCreate.createGTextField("--", 0, 17, 80, 20, this, GlobalStyle.getTextFormatCenter(loc1));
            this._runeTxt = ObjCreate.createGTextField("", 0, 35, 80, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat5));
            this._runeTxt.htmlText = Language.getString(30266);
            this._runeTxt.addEventListener(flash.events.TextEvent.LINK, this.onRuneTxtLinkHandler);
            LoaderHelp.addResCallBack(ResFileConst.player, this.onResLoaded);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            var loc1=[];
            var loc2=GlobalClass.getBitmapData(ImagesConst.RuneFightValue);
            loc1.push(loc2);
            this.toolTipData = this.getToolTipData(loc1);
            return;
        }

        /* internal  */onRuneTxtLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.Role_LookupRune, this._mode));
            return;
        }

        public setRuneLookup(arg1: Boolean): void
        {
            this._runeTxt.visible = arg1;
            return;
        }

        public updateRuneFight(arg1: string): void
        {
            if (this._runeFightTxt) 
            {
                this._runeFightTxt.text = arg1;
            }
            return;
        }

        public get toolTipData()
        {
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._toolTipData = arg1;
            return;
        }

        /* internal  */getToolTipData(arg1: Array<any>): ToolTipInfo
        {
            var loc1=arg1;
            loc1.push(Language.getString(30279));
            loc1.push(Language.getString(30280));
            loc1.push(Language.getString(30281));
            var loc2=new ToolTipInfo(NormalTooltip.ToolTipRenderType_Separate, loc1);
            return loc2;
        }

        /* internal */ /* var */_loadedBtn: GLoadedButton;

        /* internal */ /* var */_runeFightTxt: GTextFiled;

        /* internal */ /* var */_runeTxt: GTextFiled;

        /* internal */ /* var */_mode: string="自己";

        /* internal */ /* var */_toolTipData;
    }
